<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php 
	$cat_id = $_POST['cat_id'];
	$id = isset($_POST['id']) ? $_POST['id'] : '';
?>
<?php if(!($id)): ?>
<form action="<?php echo site_url('admin/dataman/weekly_prize/prize_submit');?>" name="prize_submit" id="prize_submit" method="post" enctype="multipart/form-data" >
	<input type="hidden" name="cat_id" id="cat_id" value="<?php echo $cat_id; ?>" />
	
	<div class="grid2"><span class="bold">*Rank:</span></div>
	<div class="grid6"><input type="text" maxlength="5" id="rank" name="rank" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="rank_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">*Prize name:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="prize" name="prize" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="prize_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Image:</span></div>
	<div class="grid4"><?php echo form_upload('image');?></div>
	<div class="clrboth"></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Logo:</span></div>
	<div class="grid4"><?php echo form_upload('logo');?></div>
	<div class="clrboth"></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Prize Value:</span></div>
	<div class="grid6"><input type="text" maxlength="25" id="value" name="value" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="value_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Courier name:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="courier_name" name="courier_name" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="courier_name_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Shipping date:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="shipping_date" name="shipping_date" value="" class="std-input"/><button id="shipping_date_btn">choose</button></div>
	<div class="grid2"><span class="bold red hidden" id="shipping_date_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Tracking number:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="tracking_no" name="tracking_no" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="tracking_no_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Description:</span></div>
	<div class="grid6"><textarea cols="40" rows="8" name="description" id="description"></textarea></div>
	<div class="grid2"><span class="bold red hidden" id="description_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Delivery Status:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="delivery_status" name="delivery_status" value="" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="delivery_status_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Proof Image:</span></div>
	<div class="grid4"><?php echo form_upload('proof');?></div>
	<div class="clrboth"></div>
	
	<div class="clrboth"></div>
	<div class="grid2">&nbsp;</div>
	<div class="grid6"><input type="submit" class="button" /> <?php echo loader_image('id="loader_image" class="hidden"');?></div>
	<div class="clrboth"></div>	
	
</form>
<?php else:?>
<form action="<?php echo site_url('admin/dataman/weekly_prize/prize_submit');?>" name="prize_submit" id="prize_submit" method="post" enctype="multipart/form-data" >
	<?php 
		$PRIZE = $this->week_prize_entity->init('id',$id);
	?>
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">*Rank:</span></div>
	<div class="grid6"><input type="text" maxlength="5" id="rank" name="rank" value="<?php echo $PRIZE->getRank();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="rank_error">Required field.</span></div>
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">*Prize name:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="prize" name="prize" value="<?php echo $PRIZE->getPrizeName();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="prize_error">Required field.</span></div>
	<div class="clrboth"></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Image:</span></div>
	<div class="grid4"><?php echo form_upload('image');?></div>
	<div class="grid2"><?php echo thumb($PRIZE->getPrizeImage(),40,40);?></div>
	<div class="clrboth"></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Logo:</span></div>
	<div class="grid4"><?php echo form_upload('logo');?></div>
	<div class="grid2"><?php echo thumb($PRIZE->getLogoImage(),30,30);?></div>
	<div class="clrboth"></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Prize Value:</span></div>
	<div class="grid6"><input type="text" maxlength="25" id="value" name="value" value="<?php echo $PRIZE->getValue();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="value_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Courier name:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="courier_name" name="courier_name" value="<?php echo $PRIZE->getCourierName();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="courier_name_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Shipping date:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="shipping_date" name="shipping_date" value="<?php if($PRIZE->getShippingDate()) echo sysDateTimeFormat( $PRIZE->getShippingDate(),'Y-m-d' );?>" class="std-input"/><button id="shipping_date_btn">choose</button></div>
	<div class="grid2"><span class="bold red hidden" id="shipping_date_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Tracking number:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="tracking_no" name="tracking_no" value="<?php echo $PRIZE->getTrackingNo();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="tracking_no_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Description:</span></div>
	<div class="grid6"><textarea cols="40" rows="8" name="description" id="description"><?php echo $PRIZE->getDescription();?></textarea></div>
	<div class="grid2"><span class="bold red hidden" id="description_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Delivery Status:</span></div>
	<div class="grid6"><input type="text" maxlength="255" id="delivery_status" name="delivery_status" value="<?php echo $PRIZE->getDeliveryStatus();?>" class="std-input"/></div>
	<div class="grid2"><span class="bold red hidden" id="delivery_status_error">Required field.</span></div>
	
	<div class="clrboth"></div>
	<div class="grid2"><span class="bold">Proof Image:</span></div>
	<div class="grid4"><?php echo form_upload('proof');?></div>
	<div class="grid2"><?php echo thumb($PRIZE->getProofImage(),30,30,true);?></div>
	<div class="clrboth"></div>
	
	<div class="clrboth"></div>
	<input type="hidden" name="id" id="id" value="<?php echo $id;?>" />
	<input type="hidden" name="cat_id" id="cat_id" value="<?php echo $cat_id; ?>" />
	
	<div class="grid2">&nbsp;</div>
	<div class="grid6"><input type="submit" class="button" /> <?php echo loader_image('id="loader_image" class="hidden"');?></div>
	<div class="clrboth"></div>	
	
</form>
<?php endif;?>